import $ from '../common';
Page({
  data: {
    titleHeight: $.gData().titleHeight,
    statuHeight: $.gData().statuHeight,
    isIphoneX: $.gData().isIphoneX,
    _components_modal_hide:true,
    result:[]
  },
  onLoad(e) {
    this.setData({
      order_uuid:e.order_uuid,
      zonecode: wx.getStorageSync('addresscode') || '',
    }),
    this.getinfo()
  },
  onShow() {

  },
  getinfo(){//用户信息
    $.get('/group/order/detail',{
      zonecode:this.data.zonecode,
      order_uuid:this.data.order_uuid
    },res=>{
      this.setData({
        info:res.order
      })
    })
  },
  onChange(event) {//多选变化
    this.setData({
      result: event.detail,
    });
  },
  backHome(){//返回
    $.navigateBack()
  },
  sumbit(){
    // material 器材 courselesson 课程
    let arr=''
    if(this.data.result.length==1){
      if(this.data.result[0]=='a')arr='material'
      if(this.data.result[0]=='b')arr='courselesson'
    }else if(this.data.result.length==2){
      arr='blend'
    }
    $.post('/order/refund/apply',{
      order_uuid:this.data.order_uuid,
      product_type: arr
       },res=>{
        this.close()
        this.getinfo()
    })
  },
  cancel(){//取消订单
    $.post('/group/order/close',{
      zonecode:this.data.zonecode,
      order_uuid:this.data.order_uuid
    },res=>{
      this.close()
      this.getinfo()
    })
  },
  close(){//关闭模态框
    this.setData({ _components_modal_hide: true });
  },
  showPopup() {//打开模态框
    this.setData({ _components_modal_hide: false });
  },
  godetailorpay(e){
    $.navigateTo(`/index/checkstand?order_uuid=${this.data.order_uuid}&info=${JSON.stringify(this.data.info)}`)
  }
})